define("vw.display", ["mustache", "vw.config.template"], function(mustache, template) {
	"use strict";

	var color_bar = "";
	var _chartColors = ["#2ec7c9",
		"#b6a2de",
		"#5ab1ef",
		"#ffb980",
		"#d87a80",
		"#8d98b3",
		"#e5cf0d",
		"#97b552",
		"#95706d",
		"#dc69aa",
		"#07a2a4",
		"#9a7fd1",
		"#588dd5",
		"#f5994e",
		"#c05050",
		"#59678c",
		"#c9ab00",
		"#7eb00a",
		"#6f5553",
		"#c14089"
	];

	function Init($content, data) {
		var rowindex = -1;
		$content.empty();
		$content.css({
			'max-height': $(".vw-content-container").height() - 30 + "px",
			'overflow-y': 'auto',
			'overflow-x': 'hidden'
		});
		var $container = $content;
		for(var i = 0; i < data.length; i++) {
			if(data[i].row != rowindex) {
				rowindex = data[i].row;
				var html = mustache.render(template.display_row, {
					rowindex: rowindex
				});
				$content.append(html);
				$container = $('#row_' + rowindex);
			}
			switch(data[i].type) {
				case "MultiText":
					drawDashBoard($container, data[i]);
					break;
				case "Text":
					drawText($container, data[i]);
					break;
				case "Table":
					drawTable($container, data[i]);
					break;
				case "Picture":
					drawPicture($container, data[i]);
					break;
				case "chart":
					drawChart($container, data[i]);
					break;
				case "Map":
					drawMap($container, data[i]);
					break;
				case "Migrate":
					drawMigrate($container, data[i]);
					break;
				default:
			}
			//					$('#vw_detail_' + data[i].id + "_" + data[i].term + "_" + _searchID + "_" + _uCode).on('click', function() {
			//						bDialog.open({
			//							title: '详细信息',
			//							url: 'frame.details.html?' + _fid,
			//							dialogMaxButton: false,
			//							customClass: 'blue',
			//							width: $(window).width() - 30,
			//							height: $(window).height() - 30,
			//							params: {
			//								"themeID": $(this).attr("id"),
			//								"custom": _customTheme
			//							},
			//							fnButton: false
			//						});
			//					});
		}
		//		window.onresize = function() {
		//			$('.modal-dialog').width($(window).width() - 30)
		//			$('.modal-dialog').height($(window).height() - 30)
		//		}
	}

	function handleColor() {

		var panel = $('.color-panel');
		$('li', panel).eq(0).click();

		$('.icon-color', panel).click(function() {
			$('.color-mode').show();
			$('.icon-color-close').show();

		});

		$('.icon-color-close', panel).click(function() {
			$('.color-mode').hide();
			$('.icon-color-close').hide();

		});

		$('li', panel).click(function() {
			var color = $(this).attr("data-style");
			setColor(color);
			$('.inline li', panel).removeClass("current");
			$(this).addClass("current");
			if(_themeID == "redline") {
				appendRedline();
			} else {
				GetTheme();
			}

		});
		var setColor = function(color) {
			$('#style_color').attr("href", "newLib/css/data-display" + color + ".css");
			if(color == "-dark") {
				color_bar = "#fff"
			} else {
				color_bar = "#333"
			}
		}
		$('li', panel).eq(0).click()
	}

	function drawDashBoard($dom, data) {
		//$('.dashboard-stat').css("height", data.height + 'px');
		var val = [];
		for(var i = 0; i < data.indiatorData.length; i++) {
			val[i] = {
				value: data.indiatorData[i].value,
				caption: data.indiatorData[i].caption,
				unit: data.indiatorData[i].unit
			};
		}

		var option = {
			colspan: data.colspan,
			color: data.style.color,
			icon: data.style.icon,
			title: data.title,
			indiatorData: val,
			id: data.id,
			more: data.name
		}

		if(data.detail) {
			option.detail = {
				name: data.id
			};
		}

		$dom.append(mustache.render(template.display_dashBoard, option));
	}

	function portlet($dom, data, fn) {
		var option = {
			colspan: data.colspan,
			style: data.style.style,
			color: data.style.color,
			icon: data.style.icon,
			title: data.style.title,
			id: data.id,
			fn: fn
		};
		if(data.isDetail) {
			option.detail = {
				name: data.id + "_" + data.term + "_" + _searchID + "_" + _uCode,
			};
		}

		$dom.append(mustache.render(template.display_portlet, option));
	}

	function drawText($dom, data) {
		portlet($dom, data, {});
		var $chartContainer = $('#portlet_content_' + data.id);
		$chartContainer.css({
			"height": data.height,
			'overflow': 'hidden',
			'overflow-y': 'scroll'
		});
		var val = [];
		for(var i = 0; i < data.indiatorData.length; i++) {
			val[i] = {
				value: data.indiatorData[i].value,
				caption: data.indiatorData[i].caption
			};
			if(data.indiatorData[i].is_show) {
				val[i].highlight = 'highlightSytle';
			}
		}
		var $text = $('#portlet_content_' + data.id);
		$text.append(mustache.render(template.display_text, {
			items: val
		}));
	};

	function drawChart($dom, data) {

		portlet($dom, data, {
			fnID: "vw-fn-download_" + data.id,
			fnIcon: "fa fa-download",
		});
		var $chartContainer = $('#portlet_content_' + data.id);
		$chartContainer.css("height", data.height);

		require(['echarts'], function(echarts) {

			var option = {};
			switch(data.subtype) {
				case "Column_ColumnChart": //普通柱图1
					option = normalBarAndLine(data.indiatorData, 'bar');
					//$chartContainer.css("height", 300);
					break;
				case "Bar_CustomAxisLabel2": //普通柱图2
					option = columnfigure(data.indiatorData);
					//$chartContainer.css("height", 300);
					break;
				case "Column_CustomAxisLabel3": //累计柱图1
					option = cumulativefigure(data.indiatorData, 'category', 'value', 'xAxis');
					//$chartContainer.css("height", 300);
					break;
				case "Bar_PercentStackedBar": //累计柱图2
					option = cumulativefigure(data.indiatorData, 'value', 'category', 'yAxis');
					//$chartContainer.css("height", 300);
					break;
				case "Column_ColumnTime": //时间轴柱图
					option = timecolumn(data.indiatorData);
					//$chartContainer.css("height", 300);
					break;
				case "Line_FlashingLineChart": //普通折线图
					option = normalBarAndLine(data.indiatorData, 'line');
					//$chartContainer.css("height", 300);
					break;
				case "Line_TimeChart": //时间轴折线图
					option = timeBrokenline(data.indiatorData);
					//$chartContainer.css("height", 300);
					break;
				case "Line_Column": //折柱混合图
					option = Linechart(data.indiatorData);
					//$chartContainer.css("height", 300);
					break;
				case "Pie_PieChart": //普通饼图1
					option = pirtwo(data.indiatorData, 'pie');
					//$chartContainer.css("height", 200);
					break;
				case "Pie_DonutChart": //普通饼图2
					option = pirtwo(data.indiatorData, 'pie', 'area');
					//$chartContainer.css("height", 200);
					break;
				case "Pie_MultiLevelPie": //多层饼图
					option = Multi_level(data.indiatorData);
					//$chartContainer.css("height", 200);
					break;
				case "Dashboard_PercentDashboard": //仪表盘
					option = dashboard(data.indiatorData);
					//$chartContainer.css("height", 200);
					break;
				case "Line_Area": //面积图
					option = area(data.indiatorData);
					//$chartContainer.css("height", 200);
					break;
				case "Basic_funnel1": //普通漏斗图1
					option = figuretwo(data.indiatorData, "descending");
					//$chartContainer.css("height", 300);
					break;
				case "Basic_funnel2": //普通漏斗图2
					option = figuretwo(data.indiatorData, "ascending");
					//$chartContainer.css("height", 300);
					break;
				case "Multiple_Funnels": //叠加漏斗图
					//option = figurethree(data.indiatorData)
					break;
				default:
			}

			var $chart = echarts.init($chartContainer[0]);
			$chart.setOption(option);

			$('#vw-fn-download_' + data.id).on('click', function() {
				var myDate = new Date();
				vw_common.downloadChart($chart, myDate.toLocaleString());
			});
		})
	}

	//多层饼图
	function Multi_level(indiatorData) {
		//var echartsName = arr[i].indiatorInfo.name;
		var dataArr_ny = indiatorData[0].data;
		var dataArr_fny = indiatorData[1].data;
		var dataName_ny = indiatorData[0].name;
		var dataName_fny = indiatorData[1].name;
		var dataArry_New = [];
		var dataNy, dataFny;
		var lengthData = [dataName_ny, dataName_fny];
		for(var j = 0; j < dataArr_ny.length; j++) {
			dataArry_New.push({
				value: dataArr_ny[j].value,
				name: dataArr_ny[j].label
			});
			dataNy += parseInt(dataArr_ny[j].value);
			lengthData.push(dataArr_ny[j].label);
		}
		for(var k = 0; k < dataArr_fny.length; k++) {
			dataArry_New.push({
				value: dataArr_fny[k].value,
				name: dataArr_fny[k].label
			});
			dataFny += parseInt(dataArr_fny[k].value);
		}
		var seriesData1 = [{
			value: dataNy,
			name: dataName_ny
		}, {
			value: dataFny,
			name: dataName_fny
		}];
		var option = {
			tooltip: {
				trigger: 'item',
				formatter: "{a} <br/>{b} : {c} ({d}%)"
			},
			legend: {
				data: lengthData,
				type: 'scroll',
				bottom: 10,
				//				orient: 'vertical',
				//				x: 'left',
				//				y: 'top',
				show: true
			},
			culable: false,
			series: [{
					//name: echartsName,
					type: 'pie',
					radius: [0, 40],
					center: ['55%', '55%'],
					itemStyle: {
						normal: {
							label: {
								position: 'inner'
							}
						}
					},
					data: seriesData1
				},
				{
					//name: echartsName,
					type: 'pie',
					center: ['55%', '55%'],
					radius: [50, 80],
					data: dataArry_New
				}
			]
		};
		return option
	}
	//时间轴折线图
	function timeBrokenline(indiatorData) {

		var timeArry = [],
			xAxis = [],
			legend = [],
			yAxis = [],
			series = [];
		for(var j = 0; j < indiatorData.length; j++) {
			timeArry.push(indiatorData[j].time);
		}
		for(var k = 0; k < indiatorData[0].data.length; k++) {
			xAxis.push(indiatorData[0].data[k].name);
		}
		for(var h = 0; h < indiatorData[0].data[0].data.length; h++) {
			legend.push(indiatorData[0].data[0].data[h].label);
		}
		var dataObj = {};
		for(var j = 0; j < timeArry.length; j++) {
			var dataArry = [];
			for(var k = 0; k < legend.length; k++) {
				var subDataArry = [];
				for(var h = 0; h < indiatorData[j].data.length; h++) {
					subDataArry.push(indiatorData[j].data[h].data[k].value);
				}
				dataArry.push(subDataArry);
			}
			dataObj[timeArry[j]] = dataArry;
		}
		for(var g = 0; g < legend.length; g++) {
			yAxis.push({
				'type': 'value',
				'name': legend[g]
			});
		}
		var optionArry = [];
		for(var t = 0; t < timeArry.length; t++) {
			if(t == 0) {
				var series = [];
				for(var l = 0; l < legend.length; l++) {
					if(l == 0) {
						series.push({
							'name': legend[l],
							'type': 'line',
							'markLine': {
								symbol: ['arrow', 'none'],
								symbolSize: [4, 2],
								itemStyle: {
									normal: {
										lineStyle: {
											color: 'orange'
										},
										barBorderColor: 'orange',
										label: {
											position: 'left',
											textStyle: {
												color: 'orange'
											}
										}
									}
								}
							},
							'data': dataObj[timeArry[t]][l]
						})
					} else {
						series.push({
							'name': legend[l],
							'yAxisIndex': 1,
							'type': 'line',
							'data': dataObj[timeArry[t]][l],
							itemStyle: {
								color: _chartColors[t]
							},
						})
					}
				}
				optionArry.push({
					title: {
						'text': timeArry[t]
					},
					tooltip: {
						'trigger': 'axis'
					},
					legend: {
						x: 'center',
						'data': legend
					},
					calculable: true,
					grid: {
						'x': 60,
						'y': 30
					},
					xAxis: [{
						'type': 'category',
						'axisLabel': {
							'interval': 0
						},
						'data': xAxis
					}],
					yAxis: yAxis,
					series: series
				})
			} else {
				var seriesOtherArry = [];
				for(var s = 0; s < legend.length; s++) {
					seriesOtherArry.push({
						'data': dataObj[timeArry[t]][s]
					})
				}
				optionArry.push({
					title: {
						'text': timeArry[t]
					},
					series: seriesOtherArry
				})
			}
		}

		var option = {
			timeline: {
				data: timeArry,
				autoPlay: true,
				playInterval: 1000,
				width: '80%',
				height: 20,
				x: 20
			},
			options: optionArry
		};
		return option
	}
	//时间柱图
	function timecolumn(indiatorData) {
		var timeArry = [],
			xAxis = [],
			legend = [],
			yAxis = [],
			series = [];
		for(var j = 0; j < indiatorData.length; j++) {
			timeArry.push(indiatorData[j].time);
		}
		for(var k = 0; k < indiatorData[0].data.length; k++) {
			xAxis.push(indiatorData[0].data[k].name);
		}
		for(var h = 0; h < indiatorData[0].data[0].data.length; h++) {
			legend.push(indiatorData[0].data[0].data[h].label);
		}
		var dataObj = {};
		for(var j = 0; j < timeArry.length; j++) {
			var dataArry = [];
			for(var k = 0; k < legend.length; k++) {
				var subDataArry = [];
				for(var h = 0; h < indiatorData[j].data.length; h++) {
					subDataArry.push(indiatorData[j].data[h].data[k].value);
				}
				dataArry.push(subDataArry);
			}
			dataObj[timeArry[j]] = dataArry;
		}
		for(var g = 0; g < legend.length; g++) {
			yAxis.push({
				'type': 'value',
				'name': legend[g]
			});
		}
		var optionArry = [];
		for(var t = 0; t < timeArry.length; t++) {
			if(t == 0) {
				var series = [];
				for(var l = 0; l < legend.length; l++) {
					if(l == 0) {
						series.push({
							'name': legend[l],
							'type': 'bar',
							'markLine': {
								symbol: ['arrow', 'none'],
								symbolSize: [4, 2],
								itemStyle: {
									normal: {
										lineStyle: {
											color: 'orange'
										},
										barBorderColor: 'orange',
										label: {
											position: 'left',
											textStyle: {
												color: 'orange'
											}
										}
									}
								}
							},
							'data': dataObj[timeArry[t]][l]
						})
					} else {
						series.push({
							'name': legend[l],
							'yAxisIndex': 1,
							'type': 'bar',
							'data': dataObj[timeArry[t]][l],
							itemStyle: {
								color: _chartColors[t]
							},
						})
					}
				}
				optionArry.push({
					title: {
						'text': timeArry[t]
					},
					tooltip: {
						'trigger': 'axis'
					},
					legend: {
						x: 'center',
						'data': legend
					},
					calculable: true,
					grid: {
						'x': 60,
						'y': 30
					},
					xAxis: [{
						'type': 'category',
						'axisLabel': {
							'interval': 0
						},
						'data': xAxis
					}],
					yAxis: yAxis,
					series: series
				})
			} else {
				var seriesOtherArry = [];
				for(var s = 0; s < legend.length; s++) {
					seriesOtherArry.push({
						'data': dataObj[timeArry[t]][s]
					})
				}
				optionArry.push({
					title: {
						'text': timeArry[t]
					},
					series: seriesOtherArry
				})
			}
		}
		var option = {
			timeline: {
				data: timeArry,
				autoPlay: true,
				playInterval: 1000,
				width: '80%',
				height: 20,
				x: 20
			},
			options: optionArry
		};
		return option;
	}
	//普通饼图
	function pirtwo(indiatorData, type, two_tyep) {
		var dataArr = indiatorData.data;

		var series = [],
			legend = [];
		for(var j = 0; j < dataArr.length; j++) {
			series.push({
				value: dataArr[j].value,
				name: dataArr[j].label,
				itemStyle: {
					color: _chartColors[j]
				}
			});
			legend.push(dataArr[j].label);
		}

		var option = {
			title: {
				text: '',
				subtext: '',
				x: 'center',
				show: false
			},
			calculable: true,
			legend: {
				data: legend,
				type: 'scroll',
				bottom: 10,
				//				orient: 'vertical',
				//				x: 'left',
				//				y: 'top',
				show: true
			},
			tooltip: {
				trigger: 'item',
				formatter: "{a} <br/>{b} : {c} ({d}%)"
			},
			//			grid: {
			//				x: 60,
			//				y: 30,
			//				x2: 20,
			//				y2: 50
			//			},
			series: [{
				name: " ",
				type: type,
				radius: ['5%', '60%'],
				center: ['50%', '40%'],
				roseType: two_tyep,
				sort: 'ascending',
				data: series,
				label: {
					show: true,
					length: 5
				}
			}]

		};
		return option;
	}
	// 面积图
	function area(indiatorData) {
		var legend = [],
			dataArry_secondArry = [],
			xAxis = [],
			series = [],
			yAxis = [];
		for(var h = 0; h < indiatorData.length; h++) {
			xAxis.push(indiatorData[h].name);
		}
		for(var j = 0; j < indiatorData[0].data.length; j++) {
			var dataArry_second = [];
			for(var k = 0; k < indiatorData.length; k++) {
				dataArry_second.push(indiatorData[k].data[j].value);
			};
			dataArry_secondArry.push(dataArry_second);
			legend.push(indiatorData[0].data[j].label);
		}
		for(var g = 0; g < dataArry_secondArry.length; g++) {
			yAxis.push({
				type: 'value',
				name: legend[g]
			});
			if(g == 0) {
				series.push({
					name: legend[g],
					type: 'line',
					smooth: true,
					yAxisIndex: 0,
					itemStyle: {
						normal: {
							areaStyle: {
								type: 'default'
							}
						},

						color: _chartColors[j]

					},
					data: dataArry_secondArry[g]
				});
			} else {
				series.push({
					name: legend[g],
					type: 'line',
					smooth: true,
					yAxisIndex: 1,
					itemStyle: {
						normal: {
							areaStyle: {
								type: 'default'
							}
						}
					},
					data: dataArry_secondArry[g]
				});

			}
		}

		var option = {
			title: {
				show: false
			},
			tooltip: {
				trigger: 'axis'
			},
			legend: {
				data: legend
			},
			grid: {
				x: 60,
				y: 30,
				x2: 60,
				y2: 50
			},
			calculable: true,
			xAxis: [{
				type: 'category',
				boundaryGap: false,
				data: xAxis
			}],
			yAxis: yAxis,
			series: series
		};
		return option;
	}
	// 仪表盘
	function dashboard(indiatorData) {
		var echartsData = indiatorData.data;
		var echartsValue = ((parseInt(echartsData[1].value) / parseInt(echartsData[0].value)) * 100).toFixed(2);

		var option = {

			tooltip: {
				formatter: "{a} <br/>{b} : {c}%"
			},
			grid: {
				y: 30
			},
			series: [{
				type: 'gauge',
				radius: '90%',
				detail: {
					formatter: '{value}%'
				},
				data: [{
					value: echartsValue,
					name: '完成率',
					textStyle: {
						color: color_bar
					}
				}]
			}]
		};
		return option;

	}
	// 普通漏斗图
	function figuretwo(indiatorData, type) {
		var legend = [],
			series = [];
		for(var j = 0; j < indiatorData.data.length; j++) {
			series.push({
				value: indiatorData.data[j].value,
				name: indiatorData.data[j].label,
				itemStyle: {
					color: _chartColors[j]
				},
			});
			legend.push(indiatorData.data[j].label);
		}

		var option = {
			title: {
				show: false
			},
			tooltip: {
				trigger: 'item',
				orient: 'vertical',
				x: 'left'
			},
			legend: {
				type: 'scroll',
				bottom: 10,
				//				orient: 'vertical',
				//				x: 'left',
				data: legend
			},
			calculable: true,
			series: {
				type: 'funnel',
				left: '10%',
				top: 5,
				bottom: 35,
				width: '60%',
				sort: type,
				//				gap:2,
				//				label:{
				//					normal:{
				//						show:true,
				//						position:'inside'
				//					},
				//					emphasis:{
				//						textStyle:{
				//							fontSize:20
				//						}
				//					}
				//				},
				labelLine: {
					normal: {
						length: 10,
						lineStyle: {
							width: 1,
							type: 'solid'
						}
					}
				},
				data: series
			}
		};
		return option;
	}
	// 折柱混合图
	function Linechart(indiatorData) {
		var lineName = (indiatorData.line)[0].name;
		var barName = (indiatorData.bar)[0].name;
		var lineData = (indiatorData.line)[0].data;
		var barData = (indiatorData.bar)[0].data;
		var legend = [lineName, barName];
		var lineDataArry = [],
			barDataArry = [],
			xAxis = [];

		for(var j = 0; j < lineData.length; j++) {
			xAxis.push(lineData[j].label);
			lineDataArry.push(lineData[j].value);
			barDataArry.push(barData[j].value);
		}

		var option = {
			title: {
				show: false
			},
			calculable: true,
			legend: {
				data: legend,
				x: 'center',
				y: 'top',
				padding: 30

			},
			tooltip: {
				trigger: 'axis'
			},
			grid: {
				x: 60,
				y: 50,
				x2: 50,
				y2: 50
			},
			xAxis: [{
				type: 'category',
				data: xAxis,
				axisLabel: {
					interval: 0,
					rotate: 28
				}
			}],
			yAxis: [{
					type: 'value',
					name: lineName
				},
				{
					type: 'value',
					name: barName
				}
			],
			series: [{
					name: lineName,
					type: 'line',
					data: lineDataArry,
					itemStyle: {
						color: _chartColors[j]
					},
				},
				{
					name: barName,
					type: 'bar',
					yAxisIndex: 1,
					data: barDataArry,
					itemStyle: {
						color: _chartColors[j]
					},
				}
			]
		};
		return option;
	}
	//普通柱状图
	function columnfigure(indiatorData) {
		var legend = [],
			xAxis = [],
			yAxis = [],
			series = [],
			dataArry = [];
		for(var j = 0; j < indiatorData[0].data.length; j++) {
			legend.push(indiatorData[0].data[j].label);
			var subDataArry = [];
			for(var k = 0; k < indiatorData.length; k++) {
				subDataArry.push(indiatorData[k].data[j].value);
			}
			dataArry.push(subDataArry);
			series.push({
				name: legend[j],
				type: 'bar',
				data: dataArry[j],
				color: _chartColors[j],
			})
		}
		for(var h = 0; h < indiatorData.length; h++) {
			yAxis.push(indiatorData[h].name);
		}
		var option = {
			tooltip: {},
			legend: {
				data: legend,
				type: 'scroll'
			},
			xAxis: {},
			yAxis: {
				data: yAxis
			},
			series: series
		};
		return option;
	}
	//累计柱状图
	function cumulativefigure(indiatorData, xtype, ytype, name) {
		var legend = [],
			xAxis = [],
			yAxis = [],
			series = [];
		if(name == 'xAxis') {
			for(var h = 0; h < indiatorData.length; h++) {
				xAxis.push(indiatorData[h].name);
			}
		}
		if(name == 'yAxis') {
			for(var p = 0; p < indiatorData.length; p++) {
				yAxis.push(indiatorData[p].name);
			}
		}
		var dataArry_secondArry = [];
		for(var j = 0; j < indiatorData[0].data.length; j++) {
			var dataArry_second = [];
			for(var k = 0; k < indiatorData.length; k++) {
				dataArry_second.push(indiatorData[k].data[j].value);
			};
			dataArry_secondArry.push(dataArry_second);
			legend.push(indiatorData[0].data[j].label);
			series.push({
				name: legend[j],
				type: 'bar',
				stack: '总量',
				itemStyle: {
					color: _chartColors[j]
				},
				data: dataArry_secondArry[j]
			});
		}

		var option = {
			legend: {
				data: legend,
				type: 'scroll'
			},
			xAxis: [{
				type: xtype,
				data: xAxis
			}],
			yAxis: [{
				type: ytype,
				data: yAxis
			}],
			series: series
		};
		return option
	}
	//普通柱状图+普通折线图
	function normalBarAndLine(indiatorData, type) {
		var legend = [],
			xAxis = [],
			series = [];

		for(var i = 0; i < indiatorData.data.length; i++) {
			legend[i] = indiatorData.data[i].label;
			series[i] = {
				name: legend[i],
				type: type,
				itemStyle: {
					color: _chartColors[i],
				},
				data: []
			};
		}

		for(var i = 0; i < indiatorData.length; i++) {
			xAxis[i] = indiatorData[i].name;
			for(var j = 0; j < indiatorData[i].data.length; j++) {
				series[j].data[i] = indiatorData[i].data[j].value;
			}
		}

		var option = {
			tooltip: {},
			legend: {
				data: legend,
				type: 'scroll',
				textStyle: { //图例文字的样式
					color: color_bar
				}

			},
			xAxis: {
				//设置坐标轴字体颜色和宽度  
				axisLine: {
					lineStyle: {
						color: color_bar
					}
				},
				data: xAxis
			},
			yAxis: {
				//设置坐标轴字体颜色和宽度  
				axisLine: {
					lineStyle: {
						color: color_bar
					}
				},
			},
			series: series
		};
		return option;
	}
	//地图
	function drawMap($dom, data) {

		portlet($dom, data, {});

		require(['vw.map'], function(vw_map) {
			var mapid = 'portlet_content_' + data.id;
			var vw_map_ins = vw_map();
			vw_map_ins.init(mapid, data.height);
			var map = vw_map_ins.getMap();

			//			if(data.layer) {
			//				vw_map_ins.getLayers(data.layer).addTo(map);
			//			}
			vw_map_ins.getLayersByID(0).addTo(map);
			if(_customTheme) {
				L.marker([_customTheme.lat, _customTheme.lon]).addTo(map).bindPopup(_customTheme.text).openPopup();
				map.setView([_customTheme.lat, _customTheme.lon], 13);
			} else {
				// 暂时写死，后面改完从接口获取
				map.setView([29.54837, 121.38584], 13);
			}
		})
	}
	//迁徙图
	function drawMigrate($dom, data) {
		portlet($dom, data, {});
		var $chartContainer = $('#portlet_content_' + data.id);
		$chartContainer.css("height", data.height);
		var mapid = 'portlet_content_' + data.id;
		var xqtName = data.style.title //echarts迁徙图名称
		var xqtLegendArry = []; //图例
		var geoCoordJson = {}; //所有地址及坐标
		var seriesArry = []; //详细数据数组
		for(var j = 0; j < data.indiatorData.length; j++) {
			xqtLegendArry.push(data.indiatorData[j].name);
			geoCoordJson[data.indiatorData[j].name] = [data.indiatorData[j].center[1], data.indiatorData[j].center[0]];

			for(var k = 0; k < data.indiatorData[j].data.length; k++) {

				geoCoordJson[data.indiatorData[j].data[k].name] = [data.indiatorData[j].data[k].center[1], data.indiatorData[j].data[k].center[0]];
			}
		}
		for(var g = 0; g < data.indiatorData.length; g++) {
			var dataAZDarry = [];
			var dataAZDarry2 = [];
			for(var h = 0; h < data.indiatorData[g].data.length; h++) {
				dataAZDarry.push([{
						name: data.indiatorData[g].name
					},
					{
						name: data.indiatorData[g].data[h].name,
						value: parseInt(data.indiatorData[g].data[h].value)
					}
				]);
				dataAZDarry2.push({
					name: data.indiatorData[g].data[h].name,
					value: parseInt(data.indiatorData[g].data[h].value)
				})
			}
			seriesArry.push({
				name: data.indiatorData[g].name,
				type: 'map',
				mapType: 'none',
				data: [],
				geoCoord: geoCoordJson,
				markLine: {
					smooth: true,
					effect: {
						show: true,
						scaleSize: 1,
						period: 30,
						color: '#fff',
						shadowBlur: 10
					},
					itemStyle: {
						normal: {
							borderWidth: 1,
							lineStyle: {
								type: 'solid',
								shadowBlur: 10
							}
						}
					},
					data: dataAZDarry
				},
				markPoint: {
					symbol: 'emptyCircle',
					symbolSize: function(v) {
						return 10 + v / 10
					},
					effect: {
						show: true,
						shadowBlur: 0,
						scaleSize: 0.5
					},
					itemStyle: {
						normal: {
							label: {
								show: false
							}
						}
					},
					data: dataAZDarry2
				}
			})
		}
		localStorage.setItem("_xqtName", xqtName);
		localStorage.setItem("_xqtLegend", xqtLegendArry.join("&"));
		localStorage.setItem("_xqtSeries", JSON.stringify(seriesArry));
		var html = '<div id="main" class="main" style="height: 100%;"><iframe src="qxt/example.html" style="width:100%;height:400px;"></iframe></div>'

		$('#portlet_content_444').append(html);
		$('#portlet_content_469').append(html);
	}

	//table表格
	function drawTable($dom, data) {
		portlet($dom, data, {
			fnID: "vw-fn-download_" + data.id,
			fnIcon: "fa fa-download",
		});
		var $chartContainer = $('#portlet_content_' + data.id);
		$chartContainer.css({
			"height": data.height,
			'overflow': 'hidden',
			'overflow-y': 'scroll'
		});
		var cols = [];
		var formatfields = [];
		for(var i = 0; i < data.indiatorData.column.length; i++) {
			cols[i] = data.indiatorData.column[i];

			if(data.indiatorData.renderField) {
				if(data.indiatorData.renderField == cols[i]) {
					formatfields.push(i);
				}
			}
		}

		var rows = [];
		for(var i = 0; i < data.indiatorData.data.length; i++) {
			rows[i] = {};
			var cells = [];
			for(var j = 0; j < data.indiatorData.data[i].length; j++) {
				cells[j] = data.indiatorData.data[i][j].value;
				if(formatfields.indexOf(j) != -1) {
					cells[j] = formatter(cells[j]);
				}
			}
			rows[i].cells = cells;
		}
		var $table = $('#portlet_content_' + data.id);
		$table.append(mustache.render(template.display_table, {
			cols: cols,
			rows: rows
		}));

		mergedTable($table.find('tbody')[0], 0, rows.length, 0);

		$('#vw-fn-download_' + data.id).on('click', function() {
			var myDate = new Date();
			vw_common.downloadTable($table[0], myDate.toLocaleString());
		});
	}

	return {
		init: Init
	}
})